#pragma once
#include <iostream>

const int BOOT_ADDRESS = 1;
const int BOOT_SECTOR = 2;
const int SECTOR_SIZE = 3;

struct CPU {
  CPU() {
    std::cout << "Init CPU" << std::endl;
  }

  void freeze() {
    std::cout << "runnig cpu freeze()" << std::endl;
  }
  
  void execute() {
    std::cout << "running cpu execute()" << std::endl;
  }
};

struct Memory {
  Memory() {
    std::cout << "Init Memory" << std::endl;
  }

  void load(int boot_addr, int hd_value) {
    std::cout << "memory load " << std::endl;
  }
};

struct HardDrive {
  HardDrive() {
    std::cout << "Init HardDrive" << std::endl;
  }

  int read(int boot_addr, int size) {
    std::cout << "HardDrive reading with (boot_addr, size)" << boot_addr << size << std::endl;
    return 0;
  }
};

// TODO: the facade class
struct ComputerFacade {
  ComputerFacade() {
    // TODO: this is saying facade pattern is combined many classes as One class
    cpu = new CPU();
    memory = new Memory();
    hd = new HardDrive();
  }
  ~ComputerFacade() {
    delete cpu;
    delete memory;
    delete hd;
  }

  void StartComputer() {
    cpu->freeze();
    memory->load(BOOT_ADDRESS, hd->read(BOOT_SECTOR, SECTOR_SIZE));
    cpu->execute();
  }


  private:
  CPU* cpu;
  Memory* memory;
  HardDrive *hd;
};


